//
//  WBNavigationController.swift
//  WBTest
//
//  Created by pengZY on 2017/9/25.
//  Copyright © 2017年 zhang. All rights reserved.
//

import UIKit

class WBNavigationController: UINavigationController {

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {


        if self.viewControllers.count>0 {
             viewController.hidesBottomBarWhenPushed = true
            if self.viewControllers.count == 1 {
                viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: self.title ?? "", target: self, selector: #selector(goBack),isBack:true)
            }else {
                viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.init(title: "返回", target: self, selector: #selector(goBack),isBack:true)
            }
        }
        
         super.pushViewController(viewController, animated: true)
    }
}

extension WBNavigationController{
    @objc func goBack() -> () {
        self.popViewController(animated: true)
    }
}
